package com.mchat.common.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {
    private static final String SQL = ".sql";

    private FileUtil() {
    }

    public static List<String> getSqlFiles(String path) {
        List<String> files = new ArrayList<>();
        File file = new File(path);
        File[] array = file.listFiles();
        if (array == null) {
            return files;
        }
        for (File value : array) {
            if (value.isFile()) {
                if (value.getName().endsWith(SQL)) {
                    files.add(value.getName());
                }
            } else if (value.isDirectory()) {
                files.addAll(getSqlFiles(value.getPath()));
            }
        }
        return files;
    }
}
